;;;; init-windows  -  Windows Management
;;;;
;;;;  Evgeniy Sharapov, evgeniy.sharapov@gmail.com 
;;;;
;;;;
(autoload 'window-number-mode "window-number" "Assigns numbers to windows" t)
(autoload 'winner-mode "winner" "Assigns numbers to windows" t)
(autoload 'make-interactive "init-lisp" "Makes function able to be bound to a key" t)

(when (fboundp 'window-number-mode)
  (window-number-mode))
;; allows switching between windows using Alt-Number keys 
(when (fboundp 'window-number-meta-mode)
  (window-number-meta-mode)) 
(when (fboundp 'winner-mode)
  (winner-mode 1))

(global-set-key [(control f12)] (make-interactive w32-send-sys-command #xf030 nil)) ; maximize Emacs frame

(global-set-key [(control shift f12)] (make-interactive w32-send-sys-command #xf120 nil)) ; restore original size of the Emacs frame

;; Window switching. (C-x o goes to the next window)
(windmove-default-keybindings) ;; Shift+direction

(global-set-key [(control x) (control shift o)] (lambda () (interactive) (other-window -1))) ;; back one
(global-set-key [(control x) (control o)] (lambda () (interactive) (other-window 2))) ;; forward two
;; Enlarge/shrink window
(global-set-key [(control shift left)] 'shrink-window-horizontally)
(global-set-key [(control shift right)] 'enlarge-window-horizontally)
(global-set-key [(control shift down)] 'shrink-window)
(global-set-key [(control shift up)] 'enlarge-window)

(setq initial-frame-alist
      '((left . 0) (top . 0)
        (width . 90) (height . 30)))

(provide 'init-windows)